package com.micro.frog.rbac.config;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * 配置错误页面
 *
 * @author :  ljh
 * @since : 2018/4/17
 **/
@Configuration
public class ErrorConfig implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {

    @Override
    public void customize(ConfigurableServletWebServerFactory factory) {
        //错误请求
        ErrorPage e400 = new ErrorPage(HttpStatus.BAD_REQUEST, "/error/400.html");
        //页面未找到
        ErrorPage e404 = new ErrorPage(HttpStatus.NOT_FOUND, "/error/404.html");
        //连接超时
        ErrorPage e408 = new ErrorPage(HttpStatus.REQUEST_TIMEOUT, "/error/408.html");
        //内部服务器错误
        ErrorPage e500 = new ErrorPage(HttpStatus.REQUEST_TIMEOUT, "/error/500.html");
        factory.addErrorPages(e400, e404, e408, e500);
    }
}
